

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using JTC.MiniCommerce.Core;
using JTC.MiniCommerce.Core.Configuration;
using JTC.MiniCommerce.Localization;
using JTC.MiniCommerce.Store;
using SubSonic.Utilities;

namespace JTC.MiniCommerce.Web.admin {
  public partial class sitesettings : System.Web.UI.Page {

    #region Member Variables

    private string view = string.Empty;
    private SiteSettings siteSettings = null;

    #endregion

    #region Page Events

    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e) {
      try {
        view = Utility.GetParameter("view");
        LocalizationUtility.AddLabelText(lblSiteSettings);
        LoadSiteSettings();

        switch (view) {
          case "w":
            dcWidgets.Panel.Visible = true;
            dcWidgets.SiteSettings = siteSettings;
            break;
            
          case "b":
            dcBrowsingLog.Panel.Visible = true;
            dcBrowsingLog.SiteSettings = siteSettings;
            break;
          
          case "g":
            dcGeneralSiteSettings.Panel.Visible = true;
            dcGeneralSiteSettings.SiteSettings = siteSettings;
            break;

          case "a":
            dcAnalytics.Panel.Visible = true;
            dcAnalytics.SiteSettings = siteSettings;
            break;
          case "gl":
          default:
            dcGlobalizationSettings.Panel.Visible = true;
            dcGlobalizationSettings.SiteSettings = siteSettings;
            break;
        }
      }
      catch(Exception ex) {
        Logger.Error(typeof(sitesettings).Name + ".Page_Load", ex);
        Master.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message));
      }
    }

    #endregion

    #region Methods

    #region Private

    /// <summary>
    /// Loads the site settings.
    /// </summary>
    private void LoadSiteSettings() {
      siteSettings = SiteSettings.Load();
      if (siteSettings == null) {
        siteSettings = new SiteSettings();
      }
    }

    #endregion

    #endregion

  }
}
